const mysql = require("mysql");

//1.连接
var db = mysql.createConnection({
	host:'127.0.0.1',
	user:'root',
	password:'',
	database:'xxy'
});
db.connect();
//2.发送请求（查询）
//query(干啥，回调函数)
db.query("SELECT * FROM `book`;",(err,data)=>{
	if(err){
		console.log('错了：',err);
	}else{
		console.log("成功：",JSON.stringify(data));
	}
})

